// 操作
function formatOper(val, row, index) {
		return '<a href="javascript:void(0)" onclick="editBean(' + row.id + ')">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
				+ '<a href="javascript:void(0)" onclick="deleBean(' + row.id + ')">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
};


/* --------------------------------数据展示----------------------------------------------- */
/**
 * 查询数据
 */
var searchBean = function () {
		// var params = LQ.getFormValue('#tb');
		$('#gridBean').datagrid('options').queryParams = {};//没有查询参数
		$('#gridBean').datagrid('reload');
};


// ======================================新增======================================
// 新增
var addBean = function () {
		//数据初始化
		$('#formBean').form('load', {});
		$('#dlgBean').dialog('open');
};

/**
 * 新增数据
 */
var submitForm = function () {
		$('#formBean').form('validate');
		var bean = LQ.getFormValue('#formBean');
		bean.parentId = '0';
		$.ajax({
				url: '/resume/save',
				type: 'post',
				data: JSON.stringify(bean),
				contentType: "application/json",
				dataType: 'json',
				success: function (resp) {
						layer.msg('保存成功', {time: 3000});
						searchBean();//查询数据
						$('#dlgBean').dialog('close');
				}
		});
};

/**
 * 重置新增弹出框
 */
var clearForm = function () {
		$('#formBean').form('clear');
};

// ======================================编辑======================================
/**
 * 通过主键查询用户信息
 */
var getByUserId = function (roleId, callback) {
		$.ajax({
				url: '/resume/one?id=' + roleId,
				type: 'get',
				dataType: 'json',
				success: function (resp) {
						callback && callback(resp);
				},
		});
};

// 编辑
var editBean = function (id) {
		//通过主键查询用户信息
		getByUserId(id, function (json) {
				$('#dlgBean02').dialog('open');
				$('#formBean02').form('clear');
				$('#formBean02').form('load', json);
		});
};


/**
 * 修改弹出框保存数据
 */
var updateSubmit = function () {
		$('#formBean02').form('validate');
		$.ajax({
				url: '/resume/update',
				type: 'put',
				data: LQ.getFormStr('#formBean02'),
				contentType: "application/json",
				dataType: 'json',
				success: function (resp) {
						layer.msg('保存成功', {time: 3000});
						searchBean();//查询数据
						$('#dlgBean02').dialog('close');
				}
		});
};

/**
 * 修改弹出框清除数据
 */
var updateClear = function () {
		$('#formBean02').form('clear');
};


/* --------------------------------删除----------------------------------------------- */

/**
 * 删除用户信息
 */
var deleBean = function (id) {
		layer.confirm('您确定要删除该数据吗？', {
				btn: ['确定', '取消'], //按钮
				title: "提示",
		}, function () {
				$.ajax({
						url: '/resume/delete?id=' + id,
						type: 'delete',
						contentType: "application/json",
						dataType: 'json',
						success: function (resp) {
								layer.msg('删除成功', {time: 3000});
								searchBean();//查询数据
						}
				});
		});
};


